Array.prototype.my_reduce=function(cb,...args){
    let pre,start
    if(args.length){
        pre = args[0]
        start = 0
    }else{
        pre = this[0]
        start = 1
    }
    for(let i = start; i<this.length; i++){
        pre=cb(pre,this[i],i,this)
    }
    return pre
}
let arr =[1,2,3,4,5]
let result = arr.my_reduce((pre,current,index,arr)=>{
    return pre+current
},100)
console.log(result)